//
//  GalleryHeadMoreCollectionCell.m
//  ArtDog
//
//  Created by dllo on 16/9/10.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "GalleryHeadMoreCollectionCell.h"
#import "BaseCollectionView.h"
#import "HLMacro.h"
#import "ImageViewCollectionCell.h"
#import "GalleryHotColumnList.h"
#import "ReadMainModel.h"

@interface GalleryHeadMoreCollectionCell ()

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *collectLabel;
@property (weak, nonatomic) IBOutlet BaseCollectionView *collectionView;

@end

@implementation GalleryHeadMoreCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [_collectionView registerNib:[UINib nibWithNibName:@"ImageViewCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"imageViewCollectionCell"];
    UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)_collectionView.collectionViewLayout;
    layout.itemSize = CGSizeMake(SCREEN_WIDTH / 2, SCREEN_WIDTH / 3 - 11);
    
}

- (void)setHotColumnModel:(GalleryHotColumnList *)hotColumnModel
{
    _hotColumnModel = hotColumnModel;
    _nameLabel.text = hotColumnModel.galleryName;
    _collectLabel.text = [NSString stringWithFormat:@"%@人收藏", hotColumnModel.collectionNum];
    
    if (hotColumnModel.topics == nil || hotColumnModel.topics.count == 0) {
        _collectionView.hidden = YES;
    } else {
        _collectionView.hidden = NO;
    }
    [self collectionViewProcotol];
    [_collectionView reloadData];
    
}

- (void)collectionViewProcotol
{
    [_collectionView collectionViewWithNumberOfItems:^(UICollectionView * _Nonnull collectionView, CollectionViewReturnParam * _Nonnull collectionViewParam) {
        collectionViewParam.numberOfItems =  _hotColumnModel.topics.count;
    } andCellForItemAtIndexPath:^(UICollectionView * _Nonnull collectionView, NSIndexPath * _Nonnull indexPath, CollectionViewReturnParam * _Nonnull collectionViewParam) {
        ImageViewCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"imageViewCollectionCell" forIndexPath:indexPath];
        cell.urlImage = _hotColumnModel.topics[indexPath.item].topicPic;
        collectionViewParam.returnCell = cell;
    } andDidSelectItemAtIndexPath:^(UICollectionView * _Nonnull collectionView, NSIndexPath * _Nonnull indexPath) {
        
    }];
}


@end
